package com.yao.longhan.ui.activity;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.yao.longhan.R;
import com.yao.longhan.constant.Constant;
import com.yao.longhan.model.Catalog;
import com.yao.longhan.presenter.adapter.CatalogAdapter;
import com.yao.longhan.ui.base.BaseActivity;

import java.util.ArrayList;

import butterknife.BindView;

/**
 * 需要接收title,bookId参数
 */
public class CatalogActivity extends BaseActivity {

    @BindView(R.id.rv_catalog)
    RecyclerView mRecyclerView;

    private CatalogAdapter mAdapter;

    @Override
    protected int inflateLayout() {
        return R.layout.activity_catalog;
    }

    @Override
    protected void initAfter() {
        Bundle bundle = getIntent().getExtras();
        ArrayList<Catalog> catalogList = bundle.getParcelableArrayList(Constant.BOOK_CHAPTER);
        int currentChapter = bundle.getInt(Constant.CURRENT_CHAPTER);
        String bookId = bundle.getString(Constant.BOOK_ID);
        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        mRecyclerView.setLayoutManager(layoutManager);
        mAdapter = new CatalogAdapter(this, currentChapter, bookId);
        mRecyclerView.setAdapter(mAdapter);
        mAdapter.setData(catalogList);
    }
}
